package com.juyu.miliao.authentication.service;

import java.util.concurrent.TimeUnit;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class VerificationCodeService {
	@Autowired
	private StringRedisTemplate stringRedisTemplate;

	public void sendPhoneNumVerificationCode(String phoneNum, String verificationCode) {
		stringRedisTemplate.opsForValue().set("verificationCode:phonenum:" + phoneNum, verificationCode, 10, TimeUnit.MINUTES);
	}

	public String getVerificationCodeByPhoneNum(String phoneNum) {
		return stringRedisTemplate.opsForValue().get("verificationCode:phonenum:" + phoneNum);
	}

}
